// pages/load/load.js
const app = getApp()
Page({
  data: {
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    user_id: "",
    ishide:false
  },
  onShow: function () {
    var value = wx.getStorageSync('user_id');
    if (value) {
      this.setData({
        user_id: value
      })
    } else {
      console.log('s2')
      app.login()
        .then(app.doLogin)
        .then(app.checkAuth('scope.userInfo'))
        .then(app.getUserInfo)
        .then(app.setUserData).catch(app.toLoad)
    }
  },
  checkboxChange: function(e) {
    console.log(e)
    if(e.detail.value.length>0){
      this.setData({
        ishide:true
      })
    }
  },
  bindGetUserInfo: function (e) {
    console.log(e.detail.userInfo);
    const that = this;
    console.log(that.data.user_id)
    wx.request({
      url: 'https://rtutrip.aihuodong.top/index/index/set_user_data',
      data: {
        user_id: that.data.user_id,
        user_nickname: e.detail.userInfo.nickName,
        user_avatarurl: e.detail.userInfo.avatarUrl
      },
      success(res) {
        console.log(res)
        if (res.data.ret == 200) {
          wx.switchTab({
            url: '/pages/merchant/merchant',
          })
        }
      }
    })
  }
})